package com.longlonggo.service;

import com.longlonggo.dao.base.IBaseDao;
import com.longlonggo.dao.user.IUserDao;
import com.longlonggo.entity.UserEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 系统用户业务层实现类
 *
 * @author 石马人山 me@longlonggo.com
 * @version 100-000-000<br/>
 * @Created 2017年8月9日 上午11:10:27</p>
 * @description <br/>
 */
@Service
public class UserService extends BaseService {
    /**
     * 持久化层
     */
    @Autowired
    private IUserDao userDao;

    @Override
    protected IBaseDao getDao() {
        return userDao;
    }

    public UserEntity queryByUserName(String userName) {
        Map<String, Object> map = new HashMap<>();
        map.put("userName", userName);
        List<UserEntity> userList = (List<UserEntity>) userDao.queryListByMap(map);
        if (userList == null || userList.size() < 1) {
            return null;
        }
        return userList.get(0);
    }
}
